package com.yangyongchao.dailyassistant.activity;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.KeyEvent;
import android.view.Window;

import com.yangyongchao.dailyassistant.R;

/**
 * Created by 杨永超的电脑 on 2017/9/6.
 */

public class LunchActivity extends AppCompatActivity {

    private final int SPLASH_DISPLAY_LENGHT = 2*2000;
    private Handler handler;

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().requestFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.lunch_activity);

        handler = new Handler();
        // 延迟SPLASH_DISPLAY_LENGHT时间然后跳转到MainActivity
        handler.postDelayed(new Runnable() {

            @Override
            public void run() {
                Intent intent = new Intent(LunchActivity.this,MainActivity.class);
                startActivity(intent);
                LunchActivity.this.finish();
            }
        }, SPLASH_DISPLAY_LENGHT);
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
    if(keyCode == KeyEvent.KEYCODE_BACK){
        return  true;
    }
    return  super.onKeyDown(keyCode, event);

    }
}
